#ifndef QxAbstractFactory_HPP
#define QxAbstractFactory_HPP

#include "QxAbstractPlugin.hpp"

#include <QStringList>

class BASESHARED_EXPORT QxAbstractFactory : public QxAbstractPlugin
{
  Q_OBJECT;

public:

  virtual ~QxAbstractFactory();

  QString name() const;

  static QList<QxAbstractFactory*> factories();

  template <typename Type>
  QList<Type*> getPlugins() const {
    QList<Type*> result;

    Q_FOREACH( QxAbstractPlugin* plugin, factoryPlugins() ) {
      Type* pObj = qobject_cast<Type*>( plugin );
      if ( pObj ) {
        result << pObj;
      }
    }

    return result;
  }

protected:

  QxAbstractFactory( const QString& pluginDir );

private:

  const QList<QxAbstractPlugin*>& factoryPlugins() const;

private:

  class QxAbstractFactoryPrivate;
  QScopedPointer<QxAbstractFactoryPrivate>         _pd;
};

#endif // QxAbstractFactory_HPP
